Repository navigation
fix(freshness): a hold on a backlog one read can't clear names catch-up - #4174
Conversation
A read marks messages read only when it returns every unseen one, and the pod context read returns the newest 12. Past that, the hold's "read the conversation and try again" could never clear: a webhook agent in a pod with 35 unseen read, posted, and was held again on every try. The hold now says why and names POST /api/agents/runtime/pods/:podId/catch-up with confirmSkipHistory:true. A smaller backlog keeps the read-first text. The Python webhook SDK gains catch_up(pod_id). The threshold is shared with podContextService's read count, and a test keeps the two equal. AX audit entry 140. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4VWLGaqG2kVEDDn4hY3nm
lilyshen0722
left a comment
There was a problem hiding this comment.
This is the one review for this change (D218, Tier 1): a Sonnet subagent, read-only, at e987ee1. It found nothing Major.
Checked and true:
- Catch-up: the route (
agentsRuntime.ts:2136-2166) reads the newest 20 and callsrecordCatchUp(agentSendFreshness.ts:115-124). That counts the omitted rows and advances the cursor, from a fresh cursor too. - The read rule:
recordRead(:50-62) refuses when any unseen row wasn't returned. The context route passes only the returned ids. - 12: the context read is 12 (
podContextService.ts:473-475). Theexport constreaches the CJS export through theObject.assign, and the drift test confirms it. - Hosted turns: they read only
unseenCountandmessages(nativeRuntimeService.ts:1152-1175), neverhold.message. - Old text: the small-backlog branch is byte-identical to main.
- Callers that return the hold as JSON (
agentsRuntime.ts:1874, 2614, 4605;tasksApi.ts:1083, 1220) are all on runtime-token paths, and the catch-up route takes the sameagentRuntimeAuth.agentEventServiceonly checks that a hold exists. The CLI branches on the code and never shows the text. - podId: it's
String(podId)of an id already authorized byensurePodMatch. It goes out as JSON, so there's no injection concern. - Tests: the new tests fail on main. 605 related tests pass, and the SDK passes 8 of 8. The
catch_updocstring is honest that it skips history unread.
Minors, with what was done:
- The threshold counts unseen messages, but the read's 12 rows include the agent's own. A smaller backlog interleaved with its own posts can still miss on one read and show the read-first text. That's no worse than before, and it's stated in the PR body as a known edge.
- Public MCP seats have
commonly_catch_upwithheld. No path showshold.messageto such a model, so this is low risk. The MCP server rewrites its own hint (commonly-mcp/src/tools.js:53), and I've checked that the AX entry's claim about it holds.
GATE: PASS
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
When an agent has more unseen messages than one pod context read returns, the send-time hold now names the catch-up route instead of only saying "read the conversation" (F536).
Why
A read marks messages read only when it returns every unseen one.
recordReadrefuses a truncated tail, so that history the agent never saw isn't acknowledged. The pod context read returns the newest 12 messages. On Growth's #2580 walk on prod, a fresh webhook agent sat in a pod with 35 unseen. It read the context, posted, was held, read again and was held again, following the 409's text exactly each time. The only way out wasPOST /api/agents/runtime/pods/:podId/catch-up, which the hold never named. The MCP server already rewrites its hint (commonly-mcp/src/tools.js:53), and the CLI wrapper handles the 409 in code. Raw CAP clients and the Python webhook SDK had nothing.What changes
backend/services/agentSendFreshness.ts: pastCONTEXT_READ_MESSAGES(12) unseen, the hold says why a read won't clear it. It namesPOST /api/agents/runtime/pods/<podId>/catch-up with confirmSkipHistory:trueand ends "held until you catch up". At 12 or fewer, the text is unchanged byte for byte.backend/services/podContextService.ts: the literal 12 becomes the exportedRECENT_MESSAGES_READ. A unit test keeps it equal to the freshness constant, so the two can't drift.examples/sdk/python/commonly.py:catch_up(pod_id). Its docstring says it marks older history read unseen, so call it before writing a reply._post_replydoesn't call it on its own, because that would acknowledge history the reply never saw.docs/development/agent-experience-audit.md: entry 140.Nothing else reads the text: hosted turns build their own hold text from
unseenCountandmessages(nativeRuntimeService.ts:1152-1175), andagentEventServiceonly checks that a hold exists.Proof
recordCatchUpclears it.tsc --noEmitis clean, and lint adds no new warnings.python3 -m unittest test_commonly). The new backlog test errors on main's SDK.Known edge, not fixed here
The threshold counts unseen messages, but the context read returns the newest 12 rows including the agent's own. So a backlog of, say, 10 unseen interleaved with the agent's own posts can still miss on one read and get the read-first text. That's no worse than today. Catch-up clears it either way, and the CLI wrapper's 50-row re-read covers seats.
Tier 1, with one review (Sonnet) below. It deploys with Tuesday's roll.
🤖 Generated with Claude Code
https://claude.ai/code/session_01N4VWLGaqG2kVEDDn4hY3nm